import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

ApplicationWindow {
    id: appWindow
    width: 1120
    height: 600
    minimumWidth: 380
    visible: true
    title: qsTr("Kontrast(clone)")

    header: ToolBar {
        RowLayout {
            anchors.fill: parent
            ToolButton {
                id: menu_btn
                icon.source: './icons/actions/open-menu-symbolic.png'
                onClicked: menu.popup(0, 0)

                ToolTip.text: qsTr('Open Menu')
                onHoveredChanged: ToolTip.visible = hovered
            }

            Label {
                id: menu_title
                horizontalAlignment: Qt.AlignHCenter
                verticalAlignment: Qt.AlignVCenter
                Layout.fillWidth: true
                text: 'Contrast Checker'
                font.pixelSize: 18
            }
        }
    }

    StackLayout {
        id: pages
        anchors.fill: parent
        currentIndex: 0

        MainPage {}

        FavoritePage{}

        HelpPage{}

        AboutPage{}
    }

    ////////////////////////////////////////////////////-MENU
    // ButtonGroup {
    //     buttons: menu.contentChildren
    // }

    Menu {
        id: menu
        MenuItem {
            text: qsTr("Contrast Checker")
            checkable: true
            checked: pages.currentIndex==0
            icon.source: './icons/actions/user-home-symbolic.png'
            onClicked: {
                pages.currentIndex = 0
                menu_title.text = text
            }
        }
        MenuItem {
            text: qsTr("Favorite Colors")
            checkable: true
            checked: pages.currentIndex==1
            icon.source: './icons/actions/favorite-symbolic.png'
            onClicked: {
                pages.currentIndex = 1
                menu_title.text = text
            }
        }
        MenuItem {
            text: qsTr("Help")
            checkable: true
            checked: pages.currentIndex==2
            icon.source: './icons/actions/help-contents-symbolic.png'
            onClicked: {
                pages.currentIndex = 2
                menu_title.text = text
            }
        }
        MenuItem {
            text: qsTr("About")
            checkable: true
            checked: pages.currentIndex==3
            icon.source: './icons/actions/help-about-symbolic.png'
            onClicked: {
                pages.currentIndex = 3
                menu_title.text = text
            }
        }
    }
}
